from django.contrib.auth.hashers import make_password


# Create your views here.
from rest_framework import serializers

from userapp.models import *


class RegisterSer(serializers.ModelSerializer):
    class Meta:
        model = User
        fields = '__all__'


    def create(self, validated_data):
        validated_data['password'] = make_password(validated_data['password'])
        print('密文长度：{}'.format(len(validated_data['password'])))
        instance  = User.objects.create(**validated_data)
        return instance

